'''
Created on Nov 24, 2012

@author: issa
'''

class Balancer(object):
    '''
    classdocs
    '''


    def __init__(self , mode):
        '''
        Constructor
        '''
        self.mode = mode 
        self.currentFeed = 0
    
    def setMode(self , mode):
        self.mode = mode
        self.currentFeed = 0
        
    def getCamSource(self):
        #function returns list of [source , mode]
        #source can be 0,1 and mode can be 0(observing) and 1(tracking)
        if self.mode == -1:
            #this is used in the handshaking area : two cameras are tracking
            retVal = []
            retVal.append(self.currentFeed)
            retVal.append(1) # put camera in tracking mode
            return retVal
        elif self.mode ==0:
            #only camera 0 is tracking while camera 1 is returning video feed
            retVal = []
            if self.currentFeed ==0:
                retVal.append(self.currentFeed)
                retVal.append(1)
            if self.currentFeed ==1:
                retVal.append(self.currentFeed)
                retVal.append(0)
            return retVal
        elif self.mode ==1:
            #only camera 1 is tracking while camera 0 is returning video feed
            retVal = []
            if self.currentFeed ==0:
                retVal.append(self.currentFeed)
                retVal.append(0)
            if self.currentFeed ==1:
                retVal.append(self.currentFeed)
                retVal.append(1)
            return retVal
        elif self.mode ==2:
            #both cameras returning video feed
            retVal = []
            retVal.append(self.currentFeed)
            retVal.append(0)
            return retVal          
    
    def updateFeed(self):
        self.currentFeed +=1
        self.currentFeed %=2
        
if __name__ =="__main__":
    br = Balancer(1)
    print br.getCamSource()
    print br.getCamSource()
    print br.getCamSource()
    print br.getCamSource()
    print br.getCamSource()
    print br.getCamSource()
    